<template>
  <ul class="bottom">
    <li
      v-for="item in childrenList"
      :key="item.id"
      @click="gotoContent(item.id, item.title)"
    >
      <div class="img">
        <img :src="item.cover" alt="" />
        <div class="play" v-if="isAudio">
          <van-icon name="play-circle" size="20" color="#fff" />
        </div>
      </div>
      <div class="title">{{ item.title }}</div>
      <div class="author">{{ item.author }}</div>
    </li>
  </ul>
</template>

<script>
export default {
  props: {
    childrenList: {
      type: Array,
      default() {
        return [];
      },
    },
    isAudio: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    gotoContent(id, title) {
      this.$emit("gotoContent", {
        id,
        title,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bottom {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  li {
    width: 20%;
    .img {
      width: 100%;
      position: relative;
    }
    .play {
      position: absolute;
      bottom: 14px;
      left: 8px;
    }
    img {
      width: 100%;
    }
    .title {
      text-align: left;
      font-size: 16px;
      line-height: 1.2;
      margin: 4px 0;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .author {
      font-size: 12px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }
}
</style>
